package com.sdcqjy.property.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sdcqjy.mylibrary.adapter.SuperRecyclerAdapter;
import com.sdcqjy.property.R;
import com.sdcqjy.property.mode.ListMsgMode;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 磁磁帅 on 2018/3/31.
 * 功能：
 */

public class SearchAdapter extends SuperRecyclerAdapter<ListMsgMode> {
    public SearchAdapter(Context context, List<ListMsgMode> modeList) {
        super(context, modeList);
    }

    public int getLayoutId() {
        return R.layout.item_search_list;
    }

    public SuperRecyclerAdapter.ViewHolder<ListMsgMode> getViewHolder(View view) {
        return new ViewHolder(view);
    }

    private OnAdapterClickListener onAdapterClickListener;

    public SearchAdapter setOnAdapterClickListener(OnAdapterClickListener onAdapterClickListener) {
        this.onAdapterClickListener = onAdapterClickListener;
        return this;
    }

    public class ViewHolder extends SuperRecyclerAdapter.ViewHolder<ListMsgMode> implements View.OnClickListener {
        @BindView(R.id.textTitle)
        TextView textTitle;
        @BindView(R.id.textNo)
        TextView textNo;
        @BindView(R.id.textStartTime)
        TextView textStartTime;
        @BindView(R.id.textType)
        TextView textType;
        @BindView(R.id.textTime)
        TextView textTime;
        @BindView(R.id.textPrice)
        TextView textPrice;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
            view.setOnClickListener(this);
        }

        public void setData(ListMsgMode mode) {
            super.setData(mode);
            textTitle.setText(mode.title);
            textTime.setText(mode.getFinishTime());
            textNo.setText(mode.documentCode);
            textType.setText(mode.getCategoryID());
            textStartTime.setText(mode.getTime());
            textPrice.setText(mode.taxPrice);
        }

        public void onClick(View view) {
            if (onAdapterClickListener != null) onAdapterClickListener.onAdapterClicked(mode);
        }
    }

    public interface OnAdapterClickListener {
        public void onAdapterClicked(ListMsgMode mode);
    }
}
